﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using SevenInvaders.common;

namespace SevenInvaders.LEVEL_ANA
{
    class AnaPlayer:Player
    {
        #region Atributor
        int player;
        animation animation1;

        #endregion


        public AnaPlayer(Texture2D texture, Vector2 position, int player, GameWindow gameWindow, ContentManager Content)
            : base(texture, position, player, gameWindow, Content)
        {
            this.Position = position;
            this.player = player;
            this.Velocity = new Vector2(10, 0);
            this.Window = gameWindow;


            animation1 = new animation();
            animation1.frame.X = 0;
            animation1.frame.Y = 0;
            animation1.frame.Width = 80;
            animation1.frame.Height = 82;

            animation1.frames = 6;
            animation1.fps = 5;

            current_animation = animation1;
             

        }
        
        public void Update(GameTime gameTime, KeyboardState teclado, KeyboardState teclado_anterior)
        {
            #region Movimentação
            if (teclado.IsKeyDown(Keys.Right))
            {
                this.PositionX += 10;
            }

            if (teclado.IsKeyDown(Keys.Left))
            {
                this.PositionX -= 10;
            }

            if (teclado.IsKeyDown(Keys.Up))
            {
                this.PositionY -= 10;
            }

            if (teclado.IsKeyDown(Keys.Down))
            {
                this.PositionY += 10;
            }
            #endregion

            if (teclado.IsKeyDown(Keys.Space) && !teclado_anterior.IsKeyDown(Keys.Space))
            {
                Shoot.list.Add(new Shoot(Level_Ana.anatiro, this.Position, Shoot.Direction.UP, this.Velocity));
            }

            #region Limite de tela
            if (this.PositionX > Window.ClientBounds.Width - animation1.frame.Width )
            {
                PositionX = Window.ClientBounds.Width - animation1.frame.Width;
            }

            if (this.PositionX <= 0)
            {
                this.PositionX = 0;
            }

            if (this.PositionY + this.Texture.Bounds.Height > Window.ClientBounds.Height)
            {
                this.PositionY = Window.ClientBounds.Height - this.Texture.Bounds.Height;
            }

            if (this.PositionY <= 0)
            {
                this.PositionY = 0;
            }
            #endregion
        }

       
    
       

    }
}
